<%@ page language="java"  pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="<s:url value="/style.css"/>" rel="stylesheet" type="text/css"/>
<title>Visitation List</title>
<style>
	#infoLeft {
		display:inline-block;
		width:100px;
		alignX:center;
		margin-right:30px;
	}
	#infoRight {
		display:inline-block;
		alignX:center;
	}
	#paitentInfo {
		align:left;
	}
	h3 {
		alignX:left;
	}
	#visitationTable td {
		text-align:center;
	}
	
</style>
<sx:head/>
</head>
<body>
	<jsp:include page="/navigation/navigation.jsp"/>
	<div id="mainBox">
		<center><h2>Visitation List</h2></center>			
			<s:if test='#session.currentUser.getType()=="1"'>
				<center>
<!-- 						searchVisitation -->
						<s:form name="searchVisitationForm" action="searchVisitation" method="post">
							<table>
							<tr>
								<td>Search By Content</td>
								<td><input type="text" name="searchContent"/></td>
								<td><s:select name="searchType" list="#{'0':'Diagnosis', '1':'Treatment', '2':'Comment', '3':'Patient Name'}" theme="simple"/>
							    <td><input type="submit" value="Search"/></td>
							</tr>
							</table>
						</s:form>
<!-- 						searchVisitationByDrug -->
						<s:form name="searchVisitationByDrugForm" action="searchVisitationByDrug" method="post">
						    <table>
						    <tr>
						        <td>Search By Drug</td>
						        <td><select name="searchDrugId">
										<s:iterator value="retrievedDrugs">
											<option value="<s:property value="drugId"/>"
												<s:if test="drugId==key">selected = "selected"</s:if>>
												<s:property value="drugName" />
											</option>
										</s:iterator>
								</select></td>
								<td><input type="submit" value="SearchByDrug"/></td>
						    </tr>
						    </table>
						</s:form>
				</center>
				<center>
					<s:form name="searchVisitationByTimeForm"
						action="searchVisitationByTimePeriod" method="post">
						<table>
							<tr>
								<td>Search By Date</td>
								<td><sx:datetimepicker name="startDate" label="Start Date"
										displayFormat="yyyy-MM-dd" /></td>
								<td><sx:datetimepicker name="endDate" label="End Date"
										displayFormat="yyyy-MM-dd" /></td>
								<td><input type="submit" value="SearchByDate" /></td>
							</tr>
						</table>
					</s:form>
				</center>
			</s:if>
<!-- 						searchVisitationByTimePeriod -->
		<center>
			<div>
				<h3>Visitations:</h3>
					<table id="visitationTable">
					<s:if test='actionMode=="showAll"'>
						<col width="120" />
					</s:if>
					<col width="50" />
					<col width="120" />
					<col width="120" />
					<col width="120" />
					<col width="100" />
					<col width="80" />
					<s:if test='#session.currentUser.getType()=="4"'>
						<col width="100" />
					</s:if>
					<s:if test='#session.currentUser.getType()=="1"'>
						<col width="100" />
					</s:if>
						<thead>
							<tr>
								<s:if test='actionMode=="showAll"'>
									<th>Patient</th>
								</s:if>
								<th>Date</th>
								<th>StartTime</th>		
								<th>EndTime</th>
								<th>Doctor</th>
								<th>Location</th>
								<th>Details</th>
								<s:if test='#session.currentUser.getType()=="4"'>
									<th>History</th>
								</s:if>
								<s:if test='#session.currentUser.getType()=="1"'>
									<th>Edit</th>
								</s:if>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="retrievedVisitationContents">
							<tr>
								<s:if test='actionMode=="showAll"'>
									<s:if test='#session.currentUser.getType()=="3"'>
										<td><s:property value="visitation.appointment.patient.id" /></td>
									</s:if>
									<s:else>
										<td><s:property value="visitation.appointment.patient.name" /></td>
									</s:else>
								</s:if>
								<td><s:property value="visitation.appointment.appointmentDate" /></td>
								<td><s:property value="visitation.appointment.startTime" /></td>
								<td><s:property value="visitation.appointment.endTime" /></td>
								<td><s:property value="visitation.appointment.doctor.name" /></td>
								<td><s:property value="visitation.appointment.location" /></td>								
								<td><a href="<s:url action='initVisitationViewPage'><s:param name="selectedVisitationContentId" value="%{visitationContentId}" /></s:url>">Details</a></td>
								<s:if test='#session.currentUser.getType()=="1" && #session.currentUser.id==visitation.appointment.doctor.id'>
									<td><a href="<s:url action='initVisitationUpdatePage'><s:param name="selectedVisitationContentId" value="%{visitationContentId}" /></s:url>">Edit</a></td>
								</s:if>
								<s:if test='#session.currentUser.getType()=="4"'>
									<td><a href="<s:url action='initVisitationHistoryPage'><s:param name="selectedVisitationId" value="%{visitation.visitationId}" /></s:url>">View History</a></td>
								</s:if>
							</tr>
							</s:iterator>
						</tbody>
					</table>
					</div>
			</center>
	</div>
</body>
</html>